import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class DestroySessionServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取Session对象, 如果没有Session对象则返回null
        HttpSession session = request.getSession(false);
        if (session != null) {
            // 销毁Session对象
            session.invalidate();
        }
    }
}
